package com.youhome.controller;

import com.youhome.model.HotCity;
import com.youhome.response.Result;
import com.youhome.response.ResultCode;
import com.youhome.service.HotCityService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * Created by chen365 on 2018/09/13.
 */
@Api(tags = "城市")
@RestController
public class CityController {

    @Autowired
    private HotCityService hotCityService;

    @ApiOperation(value = "热门城市", notes = "热门城市", response = HotCity.class, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @GetMapping(value = "/cities/hot")
    public Object hot() {
        HotCity record = new HotCity();
        record.setEnabled(true);
        List<HotCity> hotCities = hotCityService.selectByEnabled(record);
        return new Result<>(ResultCode.SUCCESS, hotCities);
    }
}
